home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Varsity Update 1998 August
/
SGI Varsity Update 1998 August.iso
/
dist
/
dist6.5
/
il_dev.idb
/
usr
/
include
/
il
/
ilRotZoomImg.h.z
/
ilRotZoomImg.h
Wrap
C/C++ Source or Header
|
1998-07-29
|
6KB
|
171 lines
#if 0
Copyright (c) 1991 SGI All Rights Reserved
THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI
The copyright notice above does not evidence any
actual or intended publication of such source code,
and is an unpublished work by Silicon Graphics, Inc.
This material contains CONFIDENTIAL INFORMATION that
is the property of Silicon Graphics, Inc. Any use,
duplication or disclosure not specifically authorized
by Silicon Graphics is strictly prohibited.
RESTRICTED RIGHTS LEGEND:
Use, duplication or disclosure by the Government is
subject to restrictions as set forth in subdivision
(c)(1)(ii) of the Rights in Technical Data and Computer
Software clause at DFARS 52.227-7013, and/or in similar
or successor clauses in the FAR, DOD or NASA FAR
Supplement. Unpublished- rights reserved under the
Copyright Laws of the United States. Contractor is
SILICON GRAPHICS, INC., 2011 N. Shoreline Blvd.,
Mountain View, CA 94039-7311
#endif
/*
ilRotZoomImg performs image rotation, magnification and mirroring
*/
#ifndef _ilRotZoomImg_h_
#define _ilRotZoomImg_h_
#include <il/ilAffineWarp.h>
#include <il/ilWarpImg.h>
#if defined(IL2_5_COMPAT)
#include <ifl/iflMinMax.h>
#include <ifl/iflOrientation.h>
#endif
enum ilRotZoomImgParam {
ilRZIPcenter = ilWarpImgParamLast<<1,
ilRZIPsizeToFit = ilWarpImgParamLast<<2,
ilRZIPkeepAspect = ilWarpImgParamLast<<3,
ilRZIPflipHorizontal = ilWarpImgParamLast<<4,
ilRZIPflipVertical = ilWarpImgParamLast<<5,
ilRotZoomImgParamLast = ilRZIPflipVertical
};
class ilRotZoomLocker;
class ilRotZoomImg : public ilWarpImg {
public:
iflClassListDeclare
// external api: begin
ilRotZoomImg(ilImage* img = NULL, float rotAngle=0,
float horizontalZoom=1, float verticalZoom=1,
ilResampType rs=ilNearNb);
// rotate counter-clockwise about the rotation center (in degrees)
//
void setAngle(float ang);
float getAngle() { return angle; }
// stretch horizontally and vertically
//
void setZoom(float horizontal, float vertical);
// external api: name=setUniformZoom
void setZoom(float zoom) { setZoom(zoom, zoom); }
void getZoom(float& horizontal, float& vertical)
{ resetCheck(); horizontal = zoom.x; vertical = zoom.y; }
// set the image center to be h pixels to the right of the left
// image edge and v pixels up from the bottom edge (if the center
// flag is not set, then it defaults to the image center)
//
void setCenter(float h, float v);
void getCenter(float& h, float& v)
{ resetCheck(); h = center.x; v = center.y; }
void clearCenter();
int isCenterSet() { return isSet(ilRZIPcenter); }
// if the flip flags are non-zero then the image is flipped
// in the horizontal and vertical directions, respectively
//
void setHorizontalFlip(int flip=TRUE);
int getHorizontalFlip() { return isSet(ilRZIPflipHorizontal); }
void setVerticalFlip(int flip=TRUE);
int getVerticalFlip() { return isSet(ilRZIPflipVertical); }
// if size-to-fit is set then the zoom values are adjusted in
// order to make the image fit a given width and height in pixels
//
void sizeToFit(float width, float height, int keepAspect=FALSE);
int isSizeToFit() { return isSet(ilRZIPsizeToFit); }
int isKeepAspect() { return isSet(ilRZIPkeepAspect); }
void clearSizeToFit();
void clearKeepAspect();
// external api: end
#if defined(IL2_5_COMPAT)
// XXX C++ won't let us define one constructor for a class in terms
// XXX of another, so we have to duplicate the internal implementation
// XXX of the IL 3.0 ilRotZoomImg constructor here
ilRotZoomImg(ilImage* img, float rotAngle, float xzoom, float yzoom,
iflFlip flp, ilResampType rs=ilNearNb)
: ilWarpImg(img, rs)
{
if (img && iflOrientationIsTrans[img->getOrientation()])
ilError(MM_WARNING, "ilRotZoomImg with transposed image"
" now has lower-left semantics rotation, flip, etc.");
const float minZoom = 1e-6;
angle = rotAngle;
zoom.init(iflMax(minZoom, xzoom), iflMax(minZoom, yzoom));
fit.init(0, 0);
setAllowed(ilRZIPcenter|ilRZIPsizeToFit|ilRZIPkeepAspect|
ilRZIPflipHorizontal|ilRZIPflipVertical);
if (flp & iflXFlip) setHorizontalFlip(TRUE);
if (flp & iflYFlip) setVerticalFlip(TRUE);
}
#endif
private:
float angle; // rotation angle in degrees
iflXYfloat zoom; // zoom factor
iflXYfloat center; // center of rotation
iflXYfloat fit; // size to fit
iflXYfloat normZoom; // zoom factors in this orientation
float normAngle; // rotation in this orientation
iflXYint normFlip; // flip flags in this orientation
int trans; // true if this orientation is transposed
int optimize; // optimized case selector
int ntimes; // does 2X zoom n times
iflOrientation optOrientation; // orientation for mult-90 no-zoom case
void initCoeff();
void resetOp();
void checkOptimize();
int ixs, iys, izs, ics; // input page strides
// override ilWarpImg::prepareRequest for optimized cases
virtual ilMpCacheRequest *getMpRequest(ilMpManager* parent,
int x, int y, int z, int c,
int mode=ilLMread);
virtual ilStatus prepareRequest(ilMpCacheRequest* req);
virtual ilStatus executeRequest(ilMpCacheRequest* req);
ilStatus mult90(ilMpCacheRequest* req);
ilStatus nearNbZoom(ilMpCacheRequest* req);
ilStatus initBizoom(ilMpCacheRequest* req);
ilStatus processBizoom(ilMpCacheRequest* req);
ilStatus process2XZoom(ilMpCacheRequest* req, void *src);
static ilStatus lockerDone(ilRotZoomLocker* rzcb, ilMpCallbackArg* mp);
ilStatus processPage(ilRotZoomLocker* req, ilLockRequest* page);
ilImageTile* getInputTileRequirement(const iflTile3Dint& tile, int c, int nc,
int* chans, int& inputTileCount);
friend class ilRotZoomLocker;
};
#endif